import fetch from 'utils/fetch';
import Cookies from 'js-cookie';

export function getList(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-product/production/queryTraceArchivesForReportStatistics',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 查产品类型
export function getProductTypeList() {
  const getParams = new URLSearchParams();
  getParams.append('operatorid', Cookies.get('uid'));
  getParams.append('lastlogincode', Cookies.get('lastlogincode'));
  return fetch({
    url: '/trc-service-product/production/commons/queryProductionType',
    method: 'get',
    params: getParams,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}

// 查日志类型
export function getSystemLogTypeList(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/dict/getDict',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 查日志列表
export function getSystemLogList(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/logger/queryLogger',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 查行政区划
export function getPositionList(requestParams) {
  const getParams = new URLSearchParams();
  getParams.append('operatorid', Cookies.get('uid'));
  getParams.append('lastlogincode', Cookies.get('lastlogincode'));
  return fetch({
    // url: '/trc-service-system/position/queryPositionLevel2',
    url: '/trc-service-system/position/queryPosition',
    method: 'post',
    params: getParams,
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 查询角色信息
export function getRolesList() {
  const getParams = new URLSearchParams();
  getParams.append('operatorid', Cookies.get('uid'));
  getParams.append('lastlogincode', Cookies.get('lastlogincode'));
  return fetch({
    url: '/trc-service-system/role/queryRoleAll',
    method: 'post',
    params: getParams,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 查询指定角色信息
export function getRole(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/role/queryRole',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 查询用户
export function getUsersList(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/users/queryUsers',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 保存用户
export function saveUser(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/users/saveUsers',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 编辑保存角色
export function saveRoleEdit(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/role/saveRole',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 删除角色
export function deleteRole(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/role/deleteRole',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 修复密码
export function resetPWD(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/users/resetPWD',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 查询角色功能按钮
export function queryPermission(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/permission/queryPermission',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 修改密码
export function chanUserPassword(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-system/users/changeUserPassword',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 查是否建立验证码下拉列表
export function getHaveCreateFakeList() {
  const getParams = new URLSearchParams();
  getParams.append('operatorid', Cookies.get('uid'));
  getParams.append('lastlogincode', Cookies.get('lastlogincode'));
  return fetch({
    url: '/trc-service-product/production/commons/queryDictByHaveCreateFake',
    method: 'get',
    params: getParams,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}

// 查产品排序下拉列表
export function getProductionOrdersList() {
  const getParams = new URLSearchParams();
  getParams.append('operatorid', Cookies.get('uid'));
  getParams.append('lastlogincode', Cookies.get('lastlogincode'));
  return fetch({
    url: '/trc-service-product/production/commons/queryDictByQueryTraceArchivesOrderBy',
    method: 'get',
    params: getParams,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}

// 查询企业排序下拉列表
export function getEnterpriseOrdersList() {
  const getParams = new URLSearchParams();
  getParams.append('operatorid', Cookies.get('uid'));
  getParams.append('lastlogincode', Cookies.get('lastlogincode'));
  return fetch({
    url: '/trc-service-enterprise/enterprise/commons/queryDictByQueryEnterpriseOrderBy',
    method: 'get',
    params: getParams,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}